package com.demo.java.spi.test;

import com.demo.java.spi.jdk.SuperLoggerConfiguration;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * service的加载顺序取决于jar包的加载顺序，这是JDK SPI的缺陷
 */
public class JDKServiceLoad {
    public static void main(String[] args) {
        ServiceLoader<SuperLoggerConfiguration> serviceLoader = ServiceLoader.load(SuperLoggerConfiguration.class);
        Iterator<SuperLoggerConfiguration> iter = serviceLoader.iterator();
        while (iter.hasNext()) {
            System.out.println(iter.next().shortName());
        }
    }
}
